package com.sitech.oncon.barcode.core;

import com.google.zxing.Result;
import com.google.zxing.WriterException;
import com.ykdl.member.constant.KidAction;
import com.ykdl.member.kid.R;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class CreateBarCodeActivity extends Activity {
    /** Called when the activity is first created. */
	private ImageView qrImgImageView;
	String barcode="";
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        barcode=this.getIntent().getStringExtra(KidAction.BARCODE);
        setContentView(R.layout.createbarcodeactivity);
        
        qrImgImageView = (ImageView) this.findViewById(R.id.iv_qr_image);
        Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
				.getDefaultDisplay();
        try {
			if (!barcode.equals("")) {
				Bitmap qrCodeBitmap = EncodingHandler.createTwoQRCode(barcode, (int) (display.getWidth()*0.6));
				qrImgImageView.setImageBitmap(qrCodeBitmap);
			}else {
				Toast.makeText(CreateBarCodeActivity.this, "Text can not be empty", Toast.LENGTH_SHORT).show();
			}
			
		} catch (WriterException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        findViewById(R.id.close).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				CreateBarCodeActivity.this.finish();
			}
		});
       
    }

}